<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var minimumNumbers = function (num, k) {
      const target = num % 10;
      if (num === 0) { return 0 }
      for (let i = 1; i <= 10; i++) {
        if ((k * i) % 10 === target) {
          if (num >= k * i) { // 数字够大
            return i;
          }
        }
      }
      return -1;
    };
    console.log(minimumNumbers(num = 58, k = 9))
  </script>
</body>

</html>